package com.jiayinlending.jiayindai.net.http;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by xiaohei on 2017/3/28.
 */

public class HttpManager {
    public static String ServerUrl="http://192.168.199.208:3805";
    private static OkHttpClient mClient;
    private static ServerApi mServerApi;
    private static Retrofit retrofit;

    public static ServerApi getServerApi(){
        return mServerApi;
    }
// 构造函数私有,就不能new
    private HttpManager() {

    }

    public static void init(){
        mClient = new OkHttpClient.Builder()
                .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                .build();
        retrofit = new Retrofit.Builder()
                .baseUrl(ServerUrl)
                .client(mClient)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        mServerApi = retrofit.create(ServerApi.class);
    }
}
























